home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Format CD 43
/
Amiga Format CD43 (1999)(Future Publishing)(GB)(Track 1 of 2)[!][issue 1999-09].iso
/
-serious-
/
comms
/
other
/
rxsocket
/
examples
/
tcp.rexx
< prev
next >
Wrap
OS/2 REXX Batch file
|
1999-06-14
|
2KB
|
92 lines
/*
shows how to use CreateIP() and CreateTCP()
THIS IS FOR EDUCATIONAL PORPOUSE ONLY!!!
DON'T ASK WHAT IT IS FOR.
DON'T EMAIL ME ABOUT IT.
I DON'T ASSUME ANY RESPONSABILITY ABOUT USING OF IT.
*/
l="rmh.library";if ~show("L",l) then;if ~addlib(l,0,-30) then exit
if AddLibrary("rexxsupport.library","rxsocket.library")~=0 then exit
prg=ProgramName("NOEXT")
if ~RMH_ReadArgs("FROM/A,TO/A,PORT/A/N") then do
call PrintFault(IoErr(),prg)
exit
end
if parm.2.value<1 | parm.2.value>65535 then do
say "port '"parm.2.value"' not valid"
exit
end
source = resolve(parm.0.value)
if source==-1 then do
say "from host '"parm.0.value"' not found"
exit
end
dest = resolve(parm.1.value)
if dest==-1 then do
say "to host '"parm.1.value"' not found"
exit
end
tcp.SPORT = 5000
tcp.DPORT = parm.2.value
tcp.SEQ = 1
tcp.ACK = 0
tcp.OFF = 5
tcp.FLAGS = 0
tcp.WIN = 21
tcp.URP = 1
tcp.SRC = source
tcp.DST = dest
SIZEOFIP = 20
ip.V = 4
ip.HL = 5
ip.TOS = 0
ip.LEN = SIZEOFIP+length(tcpp)
ip.ID = 100
ip.OFF = 0
ip.TTL = 65
ip.P = 6
ip.SUM = 0
ip.SRC = source
ip.DST = dest
sock = socket("INET","RAW","TCP")
if sock<0 then do
say "no socket"
exit
end
if setsockopt(sock,"IP","HDRINCL",1)<0 then do
say "no IP HDRINCL"
exit
end
remote.addrfamily = "INET"
remote.addraddr = dest
do i=0 to 255
packet = createPacket(i);
res = sendto(sock,packet,0,"REMOTE")
if res==-1 then do
say res Errno()
exit
end
end
exit
createPacket: PROCEDURE EXPOSE ip. tcp.
parse arg f
tcp.FLAGS = f
ipp = CreateIP("IP")
tcpp = CreateTCP("TCP")
return ipp || tcpp